package com.lagou.service.impI;

import com.lagou.dao.IUserDao;
import com.lagou.service.IUserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author wsl
 * @Date 2021/11/7 23:05
 * @Project_Name jdbc_spring
 */
public class UserServiceImpI implements IUserService {

    private IUserDao userDao;

    //1.构造方法的依赖注入
    /*public UserServiceImpI(IUserDao userDao) {
        this.userDao = userDao;
    }*/

    //2.set方法的依赖注入
    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void save() {
        //调用dao层的save方法
        /*ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        IUserDao userDao = (IUserDao) classPathXmlApplicationContext.getBean("userDao");
        userDao.save();*/
        userDao.save();
    }

}
